package uf.tax.laws.spider;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class Dicter {
	private Properties prop;
	private String propPath;

	public Dicter(String path) {
		propPath = path;
		prop = new Properties();
		File file = new File(path);
		if (file.exists()) {
			FileInputStream fis;
			try {
				fis = new FileInputStream(path);
				prop.load(fis);
				fis.close();
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	public String getProperty(String key, String defaultValue) {
		return prop.getProperty(key, defaultValue);
	}

	public String getProperty(String key) {
		return prop.getProperty(key);
	}

	public void put(String key, Object value) {
		prop.put(key, value);
	}

	public void save(String comment) {
		Utils.saveProperties(prop, propPath, comment);
	}

	public void save() {
		save("");
	}
}
